<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <p ref="title">{{ msg }}</p>

        <button @click="msg = '欢迎'">更新数据</button>
        <button @click="destroy">销毁实例</button>
    </div>
</body>
<script>
    new Vue({
        el:'#app',
        data:{
            msg:'welcome'
        },
        methods:{
            destroy(){
                this.$destroy()
            }
        },
        beforeCreate(){
            console.log('beforeCreate........实例刚刚创建，初始化Vue环境变量和生命周期钩子函数')
            console.log('$el：', this.$el)
            console.log('$data：', this.$data)
            console.log('msg：', this.msg)
        },
        created(){ // 常用！！！
            console.log('created........实例已经创建并初始化完成，已完成数据注入和监视')
            console.log('$el：', this.$el)
            console.log('$data：', this.$data)
            console.log('msg：', this.msg)
        },
        beforeMount(){
            console.log('beforeMount........挂载之前，此时还没关联到页面上')
            console.log('$el：', this.$el)
        },
        mounted(){ // 常用！！！
            console.log('mounted........已经挂载，与页面进行绑定')
            console.log('$el：', this.$el)
        },
        beforeUpdate(){
            console.log('beforeUpdate........内存数据已修改，但页面还没更新，页面DOM更新之前',this.$refs.title.textContent)
        },
        updated(){ // 常用！！！
            console.log('updated........页面DOM更新完成',this.$refs.title.textContent)
            // this.$nextTick()
        },
        beforeDestroy(){
            console.log('beforeDestroy........实例销毁之前')
        },
        destroyed(){
            console.log('destroyed........实例已经销毁')
        },
        

    })
</script>
</html>